<!--
    Mango - Open Source M2M - http://mango.serotoninsoftware.com
    Copyright (C) 2006-2011 Serotonin Software Technologies Inc.
    @author Matthew Lohbihler
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses/.
 -->
<h1>Overview</h1>
<p>Compound event detectors are used to detect conditions among multiple events at the same time. Instead of only noting when a value is too high or low, a device is in a given state, or if it is a given day of the week, compound detectors allow you to define logical relationships among all of these things. For example, you can detect situations when a value is too high or low and another device is in a given state, but not on a given day of the week.</p>
<p>Compound detectors act as detectors of logical conditions among existing simple detectors. As such, all of the simple detectors that you want to build relationships among must already exist. See Event Detectors and Scheduled Events for more information.</p>
<p>Note that although there are many event types, only point event detectors and scheduled events may be used in the construction of compound event detectors.</p>

<h1>Compound detector list</h1>
<p>To add a new compound detector, click the <img src="images/multi_bell_add.png"/> icon. To edit an existing detector, click the detector's name in the "Compound event detectors" list.</p>

<h1>Editing compound detectors details</h1>
<p>The detector's <b>name</b> is used to visually reference the detector during alarm conditions, or as the source for an event handler. It is recommended that a unique name be used for each detector, but it is not required.</p>
<p>The <b>Alarm level</b> determines whether the detector raises an alarm when active, and if so the severity of the alarm. See the general help page for information on Alarms.</p>
<p>Selecting <b>Return to normal</b> determines if the alarm raised when the detector is active is automatically returned to normal when the detector becomes inactive. If Return to normal is not selected, any alarms raised will need to be manually acknowledged.</p>
<p>A compound detector can be <b>Disabled</b> so that it does not run. This can be useful if you do not wish to delete the detector, but also do not currently want it enabled. Also, the system may automatically disable a detector if the point detectors or scheduled events that it depends upon are deleted or disabled.</p>
<p>To save a compound detector, click the <img src="images/save.png"/> icon at the top right. To delete an existing detector, click the <img src="images/delete.png"/> icon.</p>

<h1>Condition building</h1>
<p>
  Conditions are logical statements built from existing simple detectors (i.e. point detectors or scheduled events). 
  Typical logical operators are used to define the overall condition, including and (&amp;&amp;), or (||), and not (!). 
  Symbols are used instead of words in order to avoid ambiguity. Parentheses may be used to group sections of the statement.
</p>
<p>Point detectors and scheduled events are referenced using a shorthand derived from a type indicator ("P" for point detector, "S" for scheduled event), and the internal identification number of the item. For convenience, the list of all available simple detectors is provided in a tree below the compound detector details. The detector names are suffixed with the shorthand id that will be used. Clicking on the detector name will cause the identifier to be inserted into the condition statement at the current cursor location.</p>
<p>Clicking the <img src="images/accept.png"/> icon causes the condition statement to be validated.</p>

<h1>Operator precedence</h1>
<p>Logical operators have the following order of precedence: parentheses, not, and, or. For more information on precedence rules, see the "Mathematical precedence" section <a href="http://en.wikipedia.org/wiki/Order_of_operations" target="_blank">here</a>.</p>

